package edu.hawaii.senin.iclouds.basics;

import java.util.Comparator;

/**
 * The comparator for sorting intervals.
 * 
 * @author Pavel Senin.
 * 
 */
public class IntervalComparator implements Comparator<Interval> {

  /**
   * The comparator itself.
   * 
   * @param interval1 the first interval to compare.
   * @param interval2 the second interval to compare.
   * 
   * @return positive value if interval1 greater than interval2 0 if equals
   */
  public int compare(Interval interval1, Interval interval2) {
    Double low1 = interval1.getLowBound();
    Double low2 = interval2.getLowBound();
    return low1.compareTo(low2);
  }

}
